# 创建必要的目录
New-Item -ItemType Directory -Force -Path "data"
New-Item -ItemType Directory -Force -Path "logs"
New-Item -ItemType Directory -Force -Path "reports/daily"
New-Item -ItemType Directory -Force -Path "reports/weekly"
New-Item -ItemType Directory -Force -Path "reports/monthly"
New-Item -ItemType Directory -Force -Path "results"
New-Item -ItemType Directory -Force -Path "status"

# 初始化数据库
python -c "from modules.database import Database; db = Database(); db.close()"

# 创建示例数据文件（使用UTF-8 with BOM编码）
$data = @"
code,name,price,volume,time
000001.SZ,平安银行,16.80,123456,2024-02-22 09:30:00
600000.SH,浦发银行,11.20,98765,2024-02-22 09:30:00
"@
[System.IO.File]::WriteAllText("data/realtime_prices.csv", $data, [System.Text.Encoding]::UTF8)

# 创建系统状态文件（使用UTF-8 with BOM编码）
$status = @"
{
    "status": "running",
    "last_update": "2024-02-22 09:30:00",
    "monitored_stocks": 2,
    "system_health": "good"
}
"@
[System.IO.File]::WriteAllText("status/system_status.json", $status, [System.Text.Encoding]::UTF8)

Write-Host "数据库和目录初始化完成！" 